local proto = require("src.kit.core.proto")
local dispatcher = require("src.kit.core.event.dispatcher")
local path = require("src.kit.core.path")
local log = require("src.kit.core.data.log")
--------------------------------------------------
-- @file src/kit/boot.lua
-- @desc lua scripts runtime
-- @author doooreyn
-- @date 2020.11.14
-- @more lua脚本运行时
--------------------------------------------------
local runtime = proto.class("runtime", dispatcher)

function runtime:ctor()
    runtime.super.ctor(self)
    self:init()
end

function runtime:init()
    log:instance():warn("runtime initialize...")

    -- local fu = cc.FileUtils:getInstance()
    -- local wp = fu:getWritablePath()
    -- print("wp: ", wp)
    -- -- fi:setWritablePath("./cache")
    -- fu:setSearchPaths({"cache"})
    -- local sp = fu:getSearchPaths()
    -- local rp = fu:getDefaultResourceRootPath()
    -- print("rp: ", rp)
    -- print("fp", fu:fullPathForFilename(rp .. "README.md"))
    -- print("fp", fu:isFileExist(rp .. "README.md"))
    -- print("fp", fu:isFileExist(rp .. "CHANGELOG"))
    -- for i, v in ipairs(sp) do
    --     print(i, ":", v)
    -- end
    --
end

function runtime:start()
    --
    log:instance():save()
end

function runtime:restart()
    --
end

function runtime:update()
    --
end

function runtime:stop()
    --
end

function runtime:load()
    --
end

function runtime:reload()
    --
end

function runtime:handle_error(msg)
    print("==========", msg)
    log:instance():error(msg)
    log:instance():save()
end

return runtime
